package router

import (
	"github.com/gin-gonic/gin"
	"litter-api/app/handler"
	"litter-api/router/middleware"
	"net/http"
)

type router struct {
	Engine *gin.Engine
}

func NewRouter(Engine *gin.Engine) *router {
	return &router{
		Engine: Engine,
	}
}
func Route(r *router) {

	//欢迎页/首页
	login := handler.Login{}
	r.Engine.POST("/api/login", login.Login)
	userHandler := handler.NewUserHandler()
	userv1 := r.Engine.Group("/api/user")
	userv1.Use(middleware.CheckUserLogin())
	userv1.GET("/index", userHandler.Index)
	userv1.GET("/wallet", userHandler.Wallet)
	userv1.GET("/addr", userHandler.AddrInfo)
	userv1.POST("/addr", userHandler.SetAddr)

	r.Engine.GET("/", func(c *gin.Context) {
		c.String(http.StatusOK, "this is litter-api server")
	})

}
